<template>
<div class="content" :style='{
  "minHeight": "100vh",
  "padding": "30px",
  "backgroundSize": "cover",
  "background": "url(/assets/img/bg.jpg) no-repeat center bottom / cover",
  "height": "auto"
}'>
	<div class="text" :style='{
    "margin": "50px auto",
    "fontSize": "32px",
    "color": "rgb(51, 51, 51)",
    "textAlign": "center",
    "fontWeight": "bold"
  }'>欢迎使用高校宿舍管理系统</div>
</div>
</template>

<script setup>
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { userAPI } from '@/utils/api'

const router = useRouter()

onMounted(() => {
  init()
})

const init = () => {
  const token = localStorage.getItem('Token')
  
  if (token) {
    const sessionTable = localStorage.getItem('sessionTable')
    
    userAPI.getSession(sessionTable)
      .then((data) => {
        if (data && data.code != 0) {
          router.push('/login')
        }
      }).catch(() => {
        router.push('/login')
      })
  } else {
    router.push('/login')
  }
}
</script>

<style lang="scss" scoped>
.cardView {
  display: flex;
  flex-wrap: wrap;
  width: 100%;

  .cards {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
    justify-content: center;
    
    .card {
      width: calc(25% - 20px);
      margin: 0 10px;
      
      :deep(.el-card__body) {
        padding: 0;
      }
    }
  }
}
</style> 